package com.liuzhongni.wahahanews.cachetest;

import android.graphics.Bitmap;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by dllo on 16/1/18.
 */
public class DoubleCache implements ImageLoader.ImageCache {
    private MyMemoryCache memoryCache = new MyMemoryCache();
    private MyDiskCache diskCache = new MyDiskCache();
    @Override
    public Bitmap getBitmap(String url) {
        if(memoryCache.getBitmap(url)!=null){
            return memoryCache.getBitmap(url);
        }else if(diskCache.getBitmap(url)!=null){
            return diskCache.getBitmap(url);
        }else {
            return null;
        }
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {
        memoryCache.putBitmap(url,bitmap);
        diskCache.putBitmap(url,bitmap);
    }
}
